﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="SliderButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid Background="{TemplateBinding Background}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SliderThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Grid Background="{TemplateBinding Background}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="SliderTickBarStyle" TargetType="TickBar">
        <Setter Property="Fill" Value="{DynamicResource SliderThumbDisabled}" />
        <Setter Property="Visibility" Value="Collapsed" />
        <Style.Triggers>
            <Trigger Property="Placement" Value="Top">
                <Setter Property="Height" Value="6" />
                <Setter Property="Margin" Value="0,0,0,3" />
            </Trigger>
            <Trigger Property="Placement" Value="Bottom">
                <Setter Property="Height" Value="6" />
                <Setter Property="Margin" Value="0,3,0,0" />
                <Setter Property="Grid.Row" Value="2" />
            </Trigger>
            
            <Trigger Property="Placement" Value="Left">
                <Setter Property="Width" Value="6" />
                <Setter Property="Margin" Value="0,0,3,0" />
            </Trigger>
            <Trigger Property="Placement" Value="Right">
                <Setter Property="Width" Value="6" />
                <Setter Property="Margin" Value="3,0,0,0" />
                <Setter Property="Grid.Column" Value="2" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <ControlTemplate x:Key="HorizontalSlider" TargetType="{x:Type Slider}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto" MinHeight="{TemplateBinding Slider.MinHeight}"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions> 
            <TickBar x:Name="TopTick" Style="{StaticResource SliderTickBarStyle}" Placement="Top" />
            <Track Grid.Row="1" Name="PART_Track">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Style="{StaticResource SliderButtonStyle}" Command="Slider.DecreaseLarge" Background="{TemplateBinding Slider.Foreground}" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Height="{TemplateBinding Slider.Height}" Width="{TemplateBinding Slider.Height}" Style="{StaticResource SliderThumbStyle}"  Background="{TemplateBinding Slider.BorderBrush}"/>
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Style="{StaticResource SliderButtonStyle}" Command="Slider.IncreaseLarge" Background="{TemplateBinding Slider.Background}" />
                </Track.IncreaseRepeatButton>
            </Track>
            <TickBar x:Name="BottomTick" Style="{StaticResource SliderTickBarStyle}" Placement="Bottom"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="TickPlacement" Value="TopLeft">
                <Setter TargetName="TopTick" Property="Visibility" Value="Visible"/>
            </Trigger>
            <Trigger Property="TickPlacement" Value="BottomRight">
                <Setter TargetName="BottomTick" Property="Visibility" Value="Visible"/>
            </Trigger>
            <Trigger Property="TickPlacement" Value="Both">
                <Setter TargetName="TopTick" Property="Visibility" Value="Visible"/>
                <Setter TargetName="BottomTick" Property="Visibility" Value="Visible"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="VerticalSlider" TargetType="{x:Type Slider}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto" MinWidth="{TemplateBinding Slider.MinWidth}"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TickBar x:Name="TopTick"  Style="{StaticResource SliderTickBarStyle}" Placement="Left" />
            <Track Grid.Column="1" Name="PART_Track">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Style="{StaticResource SliderButtonStyle}" Command="Slider.DecreaseLarge" Background="{TemplateBinding Slider.Foreground}"/>
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Height="{TemplateBinding Slider.Width}" Width="{TemplateBinding Slider.Width}" Style="{StaticResource SliderThumbStyle}" Background="{TemplateBinding Slider.BorderBrush}"/>
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Style="{StaticResource SliderButtonStyle}" Command="Slider.IncreaseLarge" Background="{TemplateBinding Slider.Background}"/>
                </Track.IncreaseRepeatButton>
            </Track>
            <TickBar x:Name="BottomTick"  Style="{StaticResource SliderTickBarStyle}" Placement="Right" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="TickPlacement" Value="TopLeft">
                <Setter TargetName="TopTick" Property="Visibility" Value="Visible"/>
            </Trigger>
            <Trigger Property="TickPlacement" Value="BottomRight">
                <Setter TargetName="BottomTick" Property="Visibility" Value="Visible"/>
            </Trigger>
            <Trigger Property="TickPlacement" Value="Both">
                <Setter TargetName="TopTick" Property="Visibility" Value="Visible"/>
                <Setter TargetName="BottomTick" Property="Visibility" Value="Visible"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="FlatSlider" TargetType="{x:Type Slider}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Maximum" Value="100" />
        <Setter Property="Minimum" Value="0" />
        <Setter Property="Value" Value="0" />
        <Setter Property="Orientation" Value="Horizontal" />
        <Setter Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="Background" Value="{DynamicResource SliderTrackNormal}" />
        <Setter Property="BorderBrush">
            <Setter.Value>
                <SolidColorBrush Color="{DynamicResource BlackColor}" />
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource SliderValueDisabled}" />
                <Setter Property="Background" Value="{DynamicResource SliderTrackDisabled}" />
                <Setter Property="BorderBrush" Value="{DynamicResource SliderThumbDisabled}" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="{DynamicResource AccentColor2}" />
                    </Setter.Value>
                </Setter>
                <Setter Property="Background" Value="{DynamicResource SliderTrackHover}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="100" />
                <Setter Property="MinHeight" Value="12" />
                <Setter Property="Height" Value="12" />
                <Setter Property="Template" Value="{StaticResource HorizontalSlider}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="MinWidth" Value="12" />
                <Setter Property="Width" Value="12"/>
                <Setter Property="Height" Value="100" />
                <Setter Property="Template" Value="{StaticResource VerticalSlider}" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>
